<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 导入jQuery包 -->

</head>

<body>

    <input type="file" id="img">

    <script>
        // 构造一个formdata
        let formdata = new FormData();
        let file = document.querySelector('#img').files[0];
        formdata.append('avator', file)

        $.ajax({
            type: 'post',
            url: 'http://127.0.0.1:8006/upload',
            contentType: false,
            processData: false,
            data: formdata,
            success: res => {
            }
        })
    </script>
</body>

</html>